<?php
    class sscls_CategoryModel extends sscls_Model
    {   

        function __construct()
        {
            parent::__construct();
        }
       function getCategories()
	   {
			return $this->_db->loadObjectList('select * from categories');
	   }
	   
	    function getCategoryList()
	   {
			return $this->_db->loadObjectList('select a.*,b.name as parentname,b.id as parentid from categories as a left join categories as b on a.id=b.parentid');
	   }
	   
	   function getById($id)
	   {
			return $this->_db->loadObject('select * from categories where id='.(int)$id);
	   }
	   
	   function store1($data,$tablename)
	   {
			$result=$this->store($data,$tablename);
			return $result;
	   }
	   
	   function getItem($id)
	   {
			return $this->_db->loadObjectList('select * from article where id='.$id);
	   }
	   
	   
	   function remove($ids)
	   {
		if(is_array($ids))
			$sql='delete from categories where id in ('.implode(',',$ids).')';
		else
			$sql='delete from categories where id ='.(int)$ids;
		return $this->_db->query($sql);
	   }
    }
?>
